{extend name="public/father" /}


{block name="main"}
<style>
    .layui-form-pane .layui-form-text{padding: 0 10px;}
    .layui-form-pane .layui-form-label{background: none !important;padding-left: 2px;border: 0;color:#000;}
    .layui-form-pane .layui-form-text input, .layui-form-pane .layui-form-text textarea{border-radius: 3px !important;}
</style>

<div class="layui-card">
    <div class="layui-card-header">修改密码</div>
    <div class="layui-card-body">

        <form class="layui-form layui-form-pane" action="">

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">旧密码</label>
                <div class="layui-input-block">
                    <input type="password" name="oldpwd" required lay-verify="required" placeholder="输入原登录密码" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <input type="password" name="newpwd" required lay-verify="required" placeholder="输入新的密码" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" name="confirmpwd" required lay-verify="required" placeholder="请再次输入新的密码" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="password">修改密码</button>
                </div>
            </div>
        </form>

    </div>
</div>

{/block}


{block name="js"}
<script>
    layui.use('form', function(){
        var form = layui.form;

        form.on('submit(password)', function(data) {

            if (data.field.oldpwd.length < 6) {
                error('旧密码不能低于6位');
                return false;
            }
            if (data.field.newpwd.length < 6) {
                error('新密码不能低于6位');
                return false;
            }
            if (data.field.newpwd !== data.field.confirmpwd) {
                error('两次输入的新密码必须相同');
                return false;
            }

            $.post("{:url()}", data.field, function(res) {
                if(res.code == 1) {
                    success(res.msg);
                    jump_url("{:url('admin/account/logout')}", 1000);
                    jump_url("{:url('admin/index/index')}");
                } else {
                    error(res.msg);
                }
            }, 'json');
            return false;
        });

    });
</script>
{/block}
